//学校班级信息
$(document).ready(function(){            
	$("#sClassesInfo").jqGrid({                
		url:global_url+global_urijs+'schoolclasses_searchClassList'+global_suffix+"?sid="+global_sid,
		datatype:"json",                
		mtype:'GET', 
		height:'300',
		width:'770',
		colNames:['班级名称','学生人数','简述','创建时间','管理教师','操作','cid'],
		colModel:[                    
		{name:'cname',index:'cname',width:120,align:'center'}, 
		{name:'num_student',index:'num_student',width:120,align:'center'}, 
		{name:'desinfo',index:'desinfo',width:200,align:'center'},                    
		{name:'ctime_str',index:'ctime_str',width:120, sortable:false,align:'center'},
		{name:'tnames',index:'tnames',width:120,align:'center', sortable:false},
		{name:'option',index:'option',width:120,align:'center', sortable:false},
		{name:'cid',index:'cid',hidden:true}    
		],
		//autowidth:true,
		jsonReader: {
			root:"classList",
			page: "page",
			total: "page_count",
			records : "count",
			repeatitems: false
		},
		pager: jQuery('#sClassesPage'),
		prmNames : {page:"page",sort: "sort"},
		rowNum: 10,
		//rowList: [10, 20, 30],
		sortname: 'ctime_str',
		hidegrid: false,
		sortorder: 'desc',
		viewrecords: true,
		caption: '班级信息',
		gridComplete:function(){
			var ids=jQuery("#sClassesInfo").jqGrid('getDataIDs');
			for(var i=0; i<ids.length; i++){
				var id=ids[i];   
				del = "<a href='javascript:;' class='jqtrow' onclick='delTel(" + id + ")'>删除</a>"; 
				ma = "<a href='javascript:;' class='jqtrow' onclick='Option(" + id + ")'>管理</a>"; 
				
				jQuery("#sClassesInfo").jqGrid('setRowData', ids[i], { option: del+" "+ma });
			}
		}
	}).navGrid("#sClassesPage", { edit: false, add: false, del: false, search: false });
});

function Option(id){
	window.open(global_url+"classes/cbinfo_classesInfo"+global_suffix+"?cid="+jQuery("#sClassesInfo").jqGrid('getRowData', id).cid
						+"&tid="+global_tid);
}

function delTel(id){
	 $(function() {$( "#compPrompt" ).dialog({
		modal: true,
		resizable: false,
		buttons: {
			"删除": function() {
				var funadd = function(data1){
					if(1==data1.s){
						 $().message("删除成功!");
						 $("#sClassesInfo").trigger("reloadGrid");
						 $("#compPrompt").dialog( "close" );
					}else{
						 $().message("删除失败!");
					}
				};
				exeAjax(ajaxUrl(global_url+global_urijs+'schoolclasses_deleteClass'+global_suffix), funadd, {"cid" :jQuery("#sClassesInfo").jqGrid('getRowData', id).cid});
			},"取消": function() {
				$( this ).dialog( "close" );
			}
		}
		});
	});
}





